#pragma once

#include <cv.h>

#define WHITE 255
#define BLACK 0

inline bool operator!=(CvPoint point_one,CvPoint point_two){
	return (point_one.x != point_two.x || point_one.y != point_two.y);
}

/***************************** Function At The End **************************************

Function : bool getStartingPoint( IplImage *image, CvPoint& startingPoint, 
		   int colorThresholdLow , int colorThresholdHigh , bool reset )
Input : Image, Thresholds, Reset parameter
Output : The function will go over the image and return in an output parameter the 
		 first point that lies within the color thresholds. if no such point is
		 found the function will return false. each time the function is called
		 it will continue traversing the image to find the next point, starting from
		 the point after the last point checked. 
		 To start going over a new image or going over the same image from the beggining
		 the function should be called with the Reset set to true.

*****************************************************************************************/

/********************************* Current Step ******************************************

The function will now be able to find points between thresholds and will work on 
all greyscale.

*****************************************************************************************/

bool getStartingPoint( IplImage *image, CvPoint& startingPoint , int colorThresholdLow , int colorThresholdHigh , bool reset ){ //goes over image and always get a new starting point in threshold limits , gets grayscale image , should be reset between images

	static int currentX;
	static int currentY;

	if(reset){
		currentX = currentY = 0;
		return true;
	}

	for( ; currentX < image->width ; ++currentX ){
		for( ; currentY < image->height ; ++currentY ){
			if( ((uchar*)image->imageData + image->widthStep*currentY)[currentX] < colorThresholdLow ||
				((uchar*)image->imageData + image->widthStep*currentY)[currentX] > colorThresholdHigh ) continue;
			else{
				startingPoint.x = currentX;
				startingPoint.y = currentY;
				++currentY;
				return true;
			}
		}
		currentY = 0;
	}
	return false;
}
